import axios from 'axios'
import { Loading } from 'element-ui';
// let loadingInstance = Loading.service(options);
//设置超时时间
axios.defaults.timeout = 5000
//设置基础地址
axios.defaults.baseURL = 'http://127.0.0.1:8090'
//获取token
let token = localStorage.getItem('token')
console.log('token', token)
//请求拦截器
axios.interceptors.request.use((config) => {
    console.log(config)
    config.headers['Authorization'] = token
    Loading.service({
        text: 'Loading',
        spinner: 'el-icon-loading',
    })
    return config
})
//响应拦截
axios.interceptors.response.use((res) => {
    Loading.service({}).close()
    return res
})

export default axios